#include "MessageSystem.h"
#include "IBaseMessage.h"

// Console Debugger
#ifdef _DEBUG
#include <iostream>
using namespace std;

#define SHOWDEBUG 1
#endif


MessageSystem::MessageSystem(void)
{
}


MessageSystem::~MessageSystem(void)
{
}

void MessageSystem::ProcessMessages()
{
	while(!m_Messages.empty())
	{
		pFunc(m_Messages.front()->getID());
		
#ifdef _DEBUG
#if SHOWDEBUG
		cout << "Message \"" << m_Messages.front()->getID() << "\" processing...";
#endif
#endif

		delete m_Messages.front();
		m_Messages.pop();

#ifdef _DEBUG
#if SHOWDEBUG
		cout << " Done.\n";
#endif
#endif
	}
}

void MessageSystem::ClearMessages()
{
#ifdef _DEBUG
#if SHOWDEBUG
	cout << "Clearing messages...";
#endif
#endif

	while(!m_Messages.empty())
	{
		delete m_Messages.front();
		m_Messages.pop();
	}

#ifdef _DEBUG
#if SHOWDEBUG
	cout << "Done\n";
#endif
#endif
}

MessageSystem* MessageSystem::getInstance()
{
	static MessageSystem thisInstance;

	return &thisInstance;
}
